package com.ctshk.rpc.order.tour.mapper;

import com.ctshk.rpc.order.tour.code.IsDeletedCode;
import com.ctshk.rpc.order.tour.code.ReceiptStatusCode;
import com.ctshk.rpc.order.tour.code.ReceiptTypeCode;
import com.ctshk.rpc.order.tour.req.SeriesOrderReceiptDetailsGetInsuranceReq;
import org.apache.ibatis.annotations.Param;

/**
 * <p>
 * 收据明细表、每一笔收据，产生一个数据 Mapper 接口
 * </p>
 *
 * @author 谭响
 * @since 2021-01-18
 */
public class SeriesOrderReceiptDetailsProvider {

    public String selectGetInsuranceBySelective(@Param("req") SeriesOrderReceiptDetailsGetInsuranceReq req) {
        StringBuilder sb = new StringBuilder();
        sb.append("select ");
        sb.append("tsord.id, tsord.receipt_id, tsord.receip_json ");
        sb.append("from t_series_order_receipt_details tsord ");
        sb.append("left join t_series_order_receipt tsor on tsord.receipt_id = tsor.id ");
        sb.append("left join t_series_order_receipt_tourist tsort on tsort.receipt_id = tsor.id ");
        sb.append("where 1=1 ");
        sb.append("and tsort.order_id = #{req.orderId} ");
        sb.append("and tsort.tourist_id = #{req.touristId} ");
        sb.append("and tsor.receipt_type =" + ReceiptTypeCode.INSURANCE.getCode() + " ");
        sb.append("and tsor.receipt_status =" + ReceiptStatusCode.VALID.getCode()+ " ");
        sb.append("and tsor.is_deleted =" + IsDeletedCode.NO.getCode()+ " ");
        return sb.toString();
    }

}
